<script setup lang="ts">
// import { watchEffect } from 'vue';
import { Modal } from 'ant-design-vue';
import { useRouter, useRoute } from 'vue-router';

// const props = defineProps<{
// 	class: string;
// }>();
const router = useRouter();
const route = useRoute();

const back = () => {
	Modal.confirm({
    title: '返回后当前页面编辑的数据将丢失，确认返回?',
    onOk() {
		router.back();
    },
  });
};

const getBackText = () => {
	if (route.path.includes('/personnel/old/detail')) return '入住长者-详情';
	if (route.path.includes('/personnel/old/add')) return '入住长者-新增';
	if (route.path.includes('/care/add')) return '服务管理-添加服务包';
	return '返回';
}

// watchEffect(() => {
// 	console.log(route.meta, route.path, 'path===');
// });

</script>

<template>
	<div class="bg-white flex items-center" v-if="route.meta.hasBack">
		<a-button type="link" class="color-#000" @click="back">&lt;</a-button>
		<span class="color-#000 font-600 font-size-16">{{ getBackText() }}</span>
	</div>
</template>
